<template>
    <div class="">
        <!-- 头部导航栏 -->
        <div class="head">
            <h3>食谱秀网</h3>
            <svg class="icon icon-caidan" aria-hidden="true" @click="show = !show">
                <use xlink:href="#icon-caidan"></use>
            </svg>
            <!-- 头部隐藏栏 -->
            <transition name="fade">
                <ul class="tab" v-if="!show">
                    <router-link to="/index">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-icons_statistics"></use>
                                </svg>
                                首页
                            </span>
                        </li>
                    </router-link>
                    <router-link to="/classify">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-tag"></use>
                                </svg>
                                食材分类
                            </span>
                        </li>
                    </router-link>
                    <router-link to="/Cookbook">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-tag"></use>
                                </svg>
                                菜谱大全
                            </span>
                        </li>
                    </router-link>
                    <router-link to="/HomeCooked">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-tag"></use>
                                </svg>
                                家常菜谱
                            </span>
                        </li>
                    </router-link>
                    <router-link to="/restriction">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-star"></use>
                                </svg>
                                食物相克
                            </span>
                        </li>
                    </router-link>
                    <router-link to="/PregnantDiet">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-tag"></use>
                                </svg>
                                孕妇食谱
                            </span>
                        </li>
                    </router-link>
                    <router-link to="/FoodInformation">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-tag"></use>
                                </svg>
                                美食资讯
                            </span>
                        </li>
                    </router-link>
                </ul>
            </transition>
            <!-- 侧边栏 -->
            <div class="aside">
                <div class="phone">
                    <router-link  to="/appdownloads">
                        <img src="../../assets/images/QR code/float-icon3.png" alt="">
                    </router-link>
                </div>
                <div class="up" @click="backTop" v-show="backTopShow">
                    <img src="../../assets/images/QR code/float-icon1.png" alt="">
                </div>
            </div>
        </div>
        <!-- 搜索 -->
        <div class="sousuo">
            <svg class="icon icon-fangdajing" aria-hidden="true">
                <use xlink:href="#icon-fangdajing1"></use>
            </svg>
            <input type="text" class="sousuo1" placeholder="请输入关键字例：红烧排骨">
            <router-link to="/search">
                <input type="submit"  class="sousuo2" value="搜索">
            </router-link>
            <p>位置： 首页 > 家常菜 > 香辣鸡胗的做法</p>
        </div>
        <!-- 主体 -->
        <div class="main">
            <img src="../../assets/images/spicy/5c579c440bd31a6e8cdba09c22a38488.jpg" alt="">
            <div class="tip2">
                <p>香辣鸡胗的做法</p>
                <span>来源：chinall</span>
                <span>点击：1580</span>
                <span>2019-11-27</span>
            </div>
            <!-- 所需食材 -->
            <h3 class="title tip4" style="color: #f5680c;margin-top: 20px;margin-bottom:10px;font-size:18px;">所需食材</h3>
            <ul class="spicy">
                <li v-for="(item,index) in spicy3" :key="index">
                    <router-link to="/dishes" style="text-decoration:none;">
                        <p>{{item}}</p>
                    </router-link>
                </li>
            </ul>
            <!-- 做法共7个步骤 -->
            <h3 class="title read" style="color: #f5680c;font-size:18px;border-top:1px solid #eeeeee;">做法共7个步骤</h3>
            <ul class="reading">
                <li v-for="(item,index) in reading2" :key="index">
                    <img :src="item.src" alt="">
                    <h4>{{item.title}}</h4>
                </li>
            </ul>
            <!-- 下载 -->
            <div class="download">下载食谱秀app到手机</div>
        </div>
        <!-- 推荐部分 -->
        <div class="recommend">
            <li v-for="(item,index) in recommend" :key="index">
                <router-link to="/index">
                    <img :src="item.src" alt="">
                    <p>{{item.explanation}}</p>
                </router-link>
            </li>
        </div>
        <!-- 相关标签 -->
        <h3 class="title tip">相关标签</h3>
        <ul class="food">
            <li v-for="(item,index) in spicy2" :key="index">
                <router-link to="/dishes" style="text-decoration:none;">
                    <p>{{item}}</p>
                </router-link>
            </li>
        </ul>
        <!-- 猜你喜欢 -->
        <h3 class="title">猜你喜欢</h3>
        <ul class="foods">
            <li v-for="(item,index) in spicy" :key="index">
                <router-link to="/spicy">
                    <img :src="item.src" alt="">
                    <p>{{item.name}}</p>
                </router-link>
            </li>
        </ul>
        <!-- 相关搜索 -->
        <h3 class="titles">相关搜索</h3>
        <ul class="find">
            <li v-for="(item,index) in find2" :key="index">
                <router-link to="/dishes">
                    <p>{{item}}</p>
                </router-link>
            </li>
        </ul>
        <!-- 底部  -->
        <div class="foot">
            Copyright 食谱秀 m.shipuxiu.com <br>
            <p> 
                官方微信号: <span style="color: #ff0000;">chaoliu1588 </span> 
                <router-link to="https://m.shipuxiu.com/fenlei/">食谱分类</router-link>
                <router-link to="https://support.qq.com/products/113359/">我要吐槽</router-link>
                <router-link to="https://new.cnzz.com/v1/login.php?siteid=5433565">站长统计 </router-link>
             </p> 
        </div>

    </div>
    
</template>
<script>
export default {
    data(){
        return{
            show:true,
            spicy:[],
            recommend:[],
            find2:[],
            spicy2:[],
            spicy3:[],
            reading2:[],
            backTopShow:false
        }
    },
    mounted(){
        // 获取数据
        this.$http.get('../../data/data.json')
        .then((response)=> {
            this.spicy = response.data.spicy
            this.recommend = response.data.recommend
            this.find2 = response.data.find2
            this.spicy2 = response.data.spicy2
            this.spicy3 = response.data.spicy3
            this.reading2 = response.data.reading2
        })
        .catch(function (error) {
            console.log(error);
        })
        .then(function () {
            // always executed
        });
        window.addEventListener('scroll', this.handleScroll)
    },
    methods: {
         backTop(){
            let back = setInterval(() =>{
                 if(document.body.scrollTop||document.documentElement.scrollTop){
                    document.body.scrollTop -= 100;
                    document.documentElement.scrollTop -= 100;
                }else{
                    clearInterval(back)
                }
            });
        },
        handleScroll(){
             if (document.documentElement.scrollTop + document.body.scrollTop > 100) {
                 this.backTopShow = true;
            }else{
                 this.backTopShow = false;
            }
        }
    }
}
</script>

<style scoped>
    /* 主体 */
    .main{
        width: 100%;
        height: 230vh;
        color: #5e5e5e;
    }
    .main img{
        width: 100%;
        height: 30vh;
    }
    .tip2 p,.tip2 span{
        text-align: center;
    }
    .tip2 span{
        font-size: 12px;
        color: #acacac;
        margin: 30px;
    }
    .spicy li{
        width: 44%;
        height: 6vh;
        position: relative;
    }
    .spicy li:after{
        position: absolute;
        background: #eeeeee;
        height: 1px;
        width: 50vh;
        content: "";
        overflow: hidden;
        top: 0;
        right: 0;
    }
    .spicy li:nth-of-type(2n-1){
        border-right: 1px solid #eeeeee;
    }
    .spicy li p{
        font-size: 16px;
        color: #4c4c4c;
        margin-left: 10px;
        line-height: 6vh; 
    }
    /* 做法步骤 */
    .reading{
        margin-top: 10px;
        width: 100%;
    }
    .reading li:nth-of-type(1){
        border-top: 1px solid #e8e8e8;
    }
    .reading li{
        width: 100%;
        height: 14vh;
        padding-top: 16px;
    }
    .reading li img{
        width: 24vw;
        height: 14vh;
        float: left;
    }
    .reading li h4{
        display: block;
        width: 73vw;
        height: 3vh;
        font-size: 16px;
        color: #5f5f5f;
        float: right;
        margin: 0px 5px;
    }
    /* 下载 */
    .download{
        width: 80%;
        line-height: 5vh;
        background: rgba(253, 95, 94, 0.9);
        border-radius: 25px;
        color: #ffffff;
        font-size: 800;
        text-align: center;
        margin: 20px auto;
    }
    /* 搜索 */
    .sousuo{
        height: 10vh;
    }
    .foot{
        height: 7vh;
        margin-top: 30px;
    }
    /* 猜你喜欢 */
    .foods{
        margin-top: 10px;
        width: 100%;
        height: 118vh;
        border-top: 2px solid #efefef;
    }
    .foods li{
        width: 45%;
        height: 5vh;
        margin-top: 15px;
    }
    .foods li img{
        width: 82%;
        height: 14vh;
        margin-left: 20px;
    }
    .foods li p{
        font-size: 14px;
        text-align: center;
        color: #333333;
    }
    .recommend{
        margin-top: -110px;
        background: #ffffff;
    }
    .title{
        color: #ff3737;
        margin-left: 20px;
    }
    /* 相关搜索 */
    .find{
        width: 100%;
        height: 20vh;
        border-top: 1px solid #f2f2f2;
        font-size: 13px;
    }
    .find li{
        width: 45%;
        line-height: 4vh;
    }
    .find li a{
        color: #4c4c4c;
        text-decoration: none;
    }
    .titles{
        color: #f67622;
        margin-left: 10px;
        font-size: 18px;
        margin-bottom: 5px;
    }
    /* 相关标签 */
    .food{
        margin-top: 10px;
        width: 100%;
        height: 7vh;
        background: #ffffff;
        border-top: 2px solid #f1f1f1;
        padding-top: 10px;
    }
    .food li{
        height: 5vh;
        background: #eeeeee;
        border-radius: 20px;
        
    }
    .food li p{
        font-size: 12px;
        text-align: center;
        color: #333333;
        line-height: 5vh;
        margin: 0px 10px;
    }
    .tip{
        color: #f67521;
        font-size: 18px;
        font-weight: 540;
    }
</style>